<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
</head>
<body>
<form >
<div style="line-height:30px;margin-top: 2rem">
    <input placeholder="请输入活动名称" id="activityName" value="${activityName}"
           style="height: 32px;margin-top: 0.5%; margin-left: 5%;font-size: 24px">
    <input placeholder="请输入机构名称" id="orgName" value="${orgName}"
           style="height: 32px;margin-top: 0.5%; font-size: 24px">
    <input placeholder="请输入负责人电话" id="personTel" value="${personTel}"
           style="height: 32px;margin-top: 0.5%; font-size: 24px">
    <i class="layui-icon" style="font-size: 30px;" onclick="search()">&#xe615;</i>

    <button class="layui-btn" type="reset" style="margin-left: 5%">重置</button>
</div>

</form>
<script>
    function search() {
        console.log("搜索事件");
        window.location.href="/adminSystem/adminActivityList?activityName="+$("#activityName").val()
            +"&orgName="+$("#orgName").val()+"&personTel="+$("#personTel").val();
    }
</script>



<div>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:-37px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>

</div>


<c:if test="${sessionScope.userType==0}">


<table class="layui-table" lay-data="{width: 1800, height:600, url:'/adminSystem/adminActivityListDate?activityName=${activityName}&orgName=${orgName}&personTel=${personTel}', page:true, id:'idTest'}"
       lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{field:'id', width:40,  fixed: true}">ID</th>
        <th lay-data="{field:'activityName', width:260}">活动名称</th>
        <th lay-data="{field:'orgName', width:120, }">机构名称</th>
        <th lay-data="{field:'person', width:120}">机构负责人</th>
        <th lay-data="{field:'personTel', width:120}">负责人电话</th>
        <th lay-data="{field:'userCode', width:160}">登录账户</th>
        <th lay-data="{field:'userName', width:160}">账户名称</th>
        <th lay-data="{field:'type', width:160}">活动名称</th>
        <th lay-data="{field:'talkMoney', width:100, }">拓客费/1人</th>
        <th lay-data="{field:'type', width:200, }">活动类型</th>
        <th lay-data="{fixed: 'right', width:220, align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
    </thead>
</table>
</c:if>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="order">订单列表</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">拓客费用</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="acounting">销售结算</a>
</script>



<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj);
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'acounting'){//结算金额

                layer.open({
                    type: 2,
                    title:"进行结算",
                    shadeClose:true,
                    area: ['65%', '90%'],
                    content: '/adminSystem/toTalkMoneyaAcounting?activityId='+data.id,
                    end:function () {
                        window.location.reload();
                    }
                });

            } else if(obj.event === ''){


                //toTalkMoneyaAcounting

            } else if(obj.event === 'edit'){//
            $.cookie("couponsDate",JSON.stringify(data));
            layer.open({
                type: 2,
                title:"会员抽层设置",
                shadeClose:true,
                area: ['65%', '45%'],
                content: '/adminSystem/adminSetTalkMoney?id='+data.id+'&talkMoney='+data.talkMoney,
                end:function () {
                    window.location.reload();
                }
            });
        }else if(obj.event === 'order'){//
                layer.open({
                    type: 2,
                    title:"订单列表",
                    shadeClose:true,
                    area: ['90%', '90%'],
                    content: '/marketing/statistcsOrder?activityId='+data.id+"&key=",
                    end:function () {
                        window.location.reload();
                    }
                });
            }
    })


        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    function addCoupons() {
        $.cookie("couponsDate",null);
        layer.open({
            type: 2,
            title:"优惠券信息",
            shadeClose:true,
            area: ['90%', '90%'],
            content: '/marketing/goVoucherEdit?orgId=${orgId}&activityId=${activityId}',
            end:function () {
                window.location.reload();
            }
        });
    }








</script>





</body>
</html>
